﻿@using CollegeShop.Infrastructure.Entities.Enum
@{
    ViewBag.Title = "Orders";
    Layout = "~/Views/Shared/_Staff.cshtml";
}
<div class="main-content" style="margin-left: 190px;">
    <div class="breadcrumbs" id="breadcrumbs">
        <ul class="breadcrumb">
            <li><i class="icon-home home-icon"></i><a href="/staff/index">管理控制台</a> </li>
            <li class="active">管理首页</li>
        </ul>
        <!-- .breadcrumb -->
    </div>
    <div class="page-content">
        <div class="page-header">
            <h1>
                @{
                    CollegeShop.Infrastructure.Entities.Entity.User user = ViewBag.ManagerTitle;
                    if (user != null && user.SalesUnit != null)
                    {
                        @:@(user.SalesUnit.SalesUnitName)
                    }
                    }<small><i class="icon-double-angle-right"></i> 订单总览
                 </small>
            </h1>
        </div>
        <!-- /.page-header -->
        <div class="row" style="margin-left: 20px;">
            <div class="widget-box transparent" id="recent-box">
            <div class="widget-header">
                <h4 class="lighter smaller">
                    <i class="icon-reorder orange"></i>所有订单
                </h4>
            </div>
            <div style="text-align:right;">
                <span>本月累计销售：</span><i class="bolder red" style="font-size:18px;">@ViewBag.MonthAmount.ToString("F2") 元</i>&nbsp;&nbsp;
                <span>总累计销售：</span><i class="bolder red" style="font-size:18px;">@ViewBag.SalesAmount.ToString("F2") 元</i>
            </div>
            <div class="widget-main no-padding">
                <table class="table table-bordered table-striped">
                    <thead class="thin-border-bottom">
                        <tr>
                            <th width="8%">
                                <i class="icon-caret-right blue"></i>客户
                            </th>
                            <th width="40%">
                                <i class="icon-caret-right blue"></i>购买商品
                            </th>
                            <th width="12%">
                                <i class="icon-caret-right blue"></i>订单状态
                            </th>
                            <th width="15%">
                                <i class="icon-caret-right blue"></i>订单时间
                            </th>
                            <th width="12%">
                                <i class="icon-caret-right blue"></i>价格
                            </th>
                            <th class="hidden-480">
                                <i class="icon-caret-right blue"></i>操作
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                    @{
                        CollegeShop.Infrastructure.Entities.ItemListBox<CollegeShop.Infrastructure.Entities.Entity.Order> orders = ViewBag.Orders;
                        if (orders != null && orders.Data != null && orders.Data.Any())
                        {
                            foreach (var item in orders.Data)
                            {
                            <tr>
                                <td>
                                    @item.LinkMan
                                </td>
                                <td>
                                    @Html.Raw(item.GoodsDescript)
                                </td>
                                <td>
                                    @switch (item.State)
                                    {
                                        case OrderState.Cancel:
                                            <i class="icon-off grey"></i> <span class="grey">@OrderState.Cancel.Mapping()</span>
                                                                                        break;
                                        case OrderState.Complete:
                                            <i class="icon-ok green"></i> <span class="green">@OrderState.Complete.Mapping()</span>
                                                                                         break;
                                        case OrderState.Confirm:
                                            <i class="icon-bell orange"></i> <span class="orange">@OrderState.Confirm.Mapping()</span>
                                                                                             break;
                                        case OrderState.Payed:
                                            <i class="icon-bell orange"></i> <span class="orange">@OrderState.Payed.Mapping()</span>
                                                                                             break;
                                    }
                                </td>
                                <td>
                                    @item.OrderTime.ToString("yyyy-MM-dd HH:mm")
                                </td>
                                <td class="hidden-480">
                                    <b class="green">RMB：@item.TotalMoney</b>
                                </td>
                                <td>
                                @if (item.State == OrderState.Payed)
                                {
                                    <input type="button" class="btn btn-success btn-mini" value="交易成功" />
                                    <input type="button" class="btn btn-warning btn-mini" value="交易取消" />
                                }
                                else
                                {
                                    @item.State.Mapping()
                                }
                                </td>
                            </tr>
                            }
                        }
                        else
                        {
                        <tr>
                            <td colspan="6">
                                暂无订单
                            </td>
                        </tr>
                        }
                        }
                    </tbody>
                </table>
            </div>
           
            </div>

            <!-- /.col -->
            <div class="hr hr32 hr-dotted">
            </div>
            @Html.Raw(orders.PageItemSegment)
        </div>
        <!-- /.row -->
    </div>
    <!-- /.page-content -->
</div>
@section tail{
    <script type="text/javascript">
        $(function () {
            $('#tabOrder').trigger('click');
        });
    </script>
}